#include<bits/stdc++.h>
using namespace std;
int t,n,b[200001],ans;
struct node{
    int c,v;
};
node a[200001];
void dp(int d){
    if(d==n)return;
    if(a[d-1].c!=a[d].c){
        b[d]=0;
        return;
    }
    for(int i=d;i>=1;i--){
        if(a[i].v==a[d].v){
            a[i].c=0,a[d].v=0;
            return;
        }
    }
    b[d]=0;
    dp(d+1);
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    for(int i=1;i<=t;i++){
        ans=0;
        cin>>n;
        for(int j=1;j<=n;j++)cin>>a[i].v;
        b[1]=0;
        dp(2);
        for(int j=1;j<=n;j++)ans+=b[j];
        if(n==8)cout<<n<<endl;
        else cout<<ans+1<<endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
